home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-06-13 | 1.6 KB | 40 lines | [TEXT/EDIT] |
- ( datafiles 9 June 1988 )
- ( a possible scheme for creating and accessing data files )
-
- : "GETNAME ( -- addr ) 34 word here ;
-
- variable FCB 78 allot ( our File's Control Block )
- : +FCB ( offset -- addr ) fcb + ; ( offset into fcb )
- : 0FCB ( -- ) fcb 80 0 fill ;
- : FTRAP ( -- ) fcb >abs ,$ 205E ; ( movea.l [ps]+,a0 )
-
- : CLOSE ( -- ) ftrap ,$ A001 ftrap ,$ A013 ; ( close & flush )
- : ?DERROR ( -- ) 16 +fcb @ ?dup IF ( if result not zero )
- ." DiskError" . close abort THEN ; ( report & abort )
-
- : EOF ( -- dbytes ) ftrap ,$ A011 30 +fcb @ ; ( _GetEOF )
- : !SIZE ( bytes -- ) 38 +fcb ! ; ( set bytes-to-read or write )
- : !NAME ( name.addr -- ) >abs 0fcb 18 +fcb 2! ; ( set name )
-
- : NEW ( name.addr -- ) !name ftrap ,$ A008 ?derror ; ( _Create )
- : "NEW ( -- ) "getname new ; ( get a name and create a file )
-
- : OPEN ( -- ) ftrap ,$ A000 ?derror ; ( _Open the file )
- : "OPEN ( -- ) "getname !name 1 27 +fcb c! open ; ( read only )
- : "RWOPEN ( -- ) "getname !name open ; ( read and write )
-
- : READ ( dabs.addr -- ) ( allows read outside of dictionary )
- 32 +fcb 2! ( set read buffer pointer )
- ftrap ,$ A002 ?derror ; ( _Read )
- : WRITE ( dabs.addr -- )
- 32 +fcb 2! ( set write buffer pointer )
- ftrap ,$ A003 ?derror ; ( _Write )
-
- : DISK ( n -- ) ( set the default volume to n )
- 0fcb 22 +fcb ! ftrap ,$ A015 ?derror ; ( _SetVol )
-
- : "LIST ( -- ) ( list a file )
- "open eof dup 0< IF abs THEN ( determine file length )
- room 44 - min dup !size ( set bytes to be read )
- pad dup >abs read close swap type ; ( read & type data )
-